home *** CD-ROM | disk | FTP | other *** search
- Path: gryphon.phoenix.net!usenet
- From: brucew@phoenix.net (Bruce Wedding)
- Newsgroups: comp.lang.c
- Subject: Re: pointers
- Date: Tue, 27 Feb 1996 00:20:43 GMT
- Organization: BranPaul Systems
- Message-ID: <4gtir6$d68@gryphon.phoenix.net>
- References: <4gqh8g$bo4@news.bu.edu>
- NNTP-Posting-Host: dial141.phoenix.net
- X-Newsreader: Moe's Newsreader
-
- In comp.lang.c
- lachesis@cs.bu.edu (wai yip) wrote:
-
- >can someone who knows a lot about pointers help me with this
-
- >int i=3,*p;
- >
- >with the above declaration, what would the bottom lines do?
- >*p=&i;
- This stores the adress of i at wherever p points. Not good.
-
- >p=i;
- This points p at the address 3. Not good.
-
- >*p=i;
- This stores 3 at whatever address p is pointing. May be good or
- bad. Depends if p points at valid memory. I prefer to
- explicitly initialize p.
-
- >p=&i;
-
- Assigns the address of i to p. This is the only correct
- statement here, in this context.
-
-
- Bruce D. Wedding Have Compiler, Will Travel!
- Perspicacious Programming Performed Promptly
- Katy, Texas, USA, Planet Earth, Milkyway Galaxy, Known Universe
-
-